<?php
/**
 * Journal controller
 * 
 * @author    Evgeny Utehin <utehin@ebola.com.ua>
 * @copyright Copyright &copy; 2014 Ebola Communications 
 * @link      http://www.ebola.com.ua/ 
 */
class JournalController extends CController
{
    public function init()
    {
        $this->layout = $this->module->layout;
    }

    public function actionIndex()
    {
        $model = new UserActivity;
        $class = get_class($model);

        if (isset($_GET[$class])) {
            $model->setAttributes($_GET[$class], false);
        }

        $this->render($this->module->indexView, compact('model'));
    }

    public function actionView()
    {
        $logId = Yii::app()->request->getQuery('id', false);

        if (UserActivity::model()->exists('id = :id', array(':id' => $logId))) {
            $logModel = UserActivity::model()->findByPk($logId);

            $loggedModel = new $logModel->entity;
        }

        $this->render($this->module->itemView, compact('logModel', 'loggedModel'));
    }
}
